package com.dh.cheesestrip.Util;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.youth.banner.Banner;
import com.youth.banner.loader.ImageLoader;

import java.util.List;

/**
 * 图像工具类
 */
public class ImageUtil {

//    public static void init(Context context) {
//        Fresco.initialize(context);
//    }

    public static void setImage(Context context, ImageView imageView, String imagePath) {
//        Uri uri = Uri.parse(imagePath);
//        draweeView.setImageURI(uri);
        Glide.with(context).load(imagePath).into(imageView);
    }

    public static void setImageRes(ImageView imageView, int res) {
//        Uri uri = Uri.parse("res://"+ Config.PACKAGE_NAME+"/"+res);
//        draweeView.setImageURI(uri);
        imageView.setImageResource(res);

    }

    public static void startBanner(Banner banner, List<String> imagePathList){
        banner.setImageLoader(new GlideImageLoader())
                .setImages(imagePathList)
                .start();
    }

    private static class GlideImageLoader implements ImageLoader {
        @Override
        public void displayImage(Context context, Object path, ImageView imageView) {
            ImageUtil.setImage(context,imageView,path+"");
        }
    }

}
